class Solution(object):
    def corpFlightBookings(self, bookings, n):
        lazy = [0] * 4 * n

        def update(node, ls, rs, l, r, val):
            if l <= ls and r >= rs:
                lazy[node] += val
            else:
                lazy[2 * node + 1] += lazy[node]
                lazy[2 * node + 2] += lazy[node]
                lazy[node] = 0
                mid = (ls + rs) // 2
                if l <= mid:
                    update(2 * node + 1, ls, mid, l, r, val)
                if r >= mid + 1:
                    update(2 * node + 2, mid + 1, rs, l, r, val)

        def query(node, ls, rs, id):
            if id == ls == rs:
                return lazy[node]
            else:
                lazy[2 * node + 1] += lazy[node]
                lazy[2 * node + 2] += lazy[node]
                lazy[node] = 0
                mid = (ls + rs) // 2
                if id <= mid:
                    return query(2 * node + 1, ls, mid, id)
                else:
                    return query(2 * node + 2, mid + 1, rs, id)

        for f, l, s in bookings:
            update(0, 0, n - 1, f - 1, l - 1, s)

        out = [0] * n
        for i in range(n):
            out[i] = query(0, 0, n - 1, i)
        return out
